import Content from '@/sheep/layouts/content.vue';
import { request } from '@/sheep/request';
import { CRUD } from '@/sheep/request/crud';

const route = {
  path: 'activity',
  name: 'shop.admin.activity',
  component: Content,
  meta: {
    title: '营销',
  },
  children: [
    {
      path: 'activity',
      name: 'shop.admin.activity.activity',
      component: () => import('./activity/index.vue'),
      meta: {
        title: '营销活动',
      },
    },
    {
      path: 'list',
      name: 'shop.admin.activity.list',
      component: () => import('./activity/list.vue'),
      meta: {
        title: '营销活动',
      },
    },
    {
      path: 'groupon',
      name: 'shop.admin.activity.groupon',
      component: () => import('./groupon/index.vue'),
      meta: {
        title: '拼团列表',
      },
    },
  ],
};

const api = {
  activity: {
    ...CRUD('shop/admin/activity/activity', ['detail', 'add', 'edit', 'delete']),
    list: (type, params) =>
      request({
        url: `shop/admin/activity/activity/list/${type}`,
        method: 'GET',
        params,
      }),
    skus: (params) =>
      request({
        url: 'shop/admin/activity/activity/skus',
        method: 'GET',
        params,
      }),
    recyclebin: (type, params) =>
      request({
        url: `shop/admin/activity/activity/recyclebin/${type}`,
        method: 'GET',
        params,
      }),
    select: (type, params) =>
      request({
        url: `shop/admin/activity/activity/select/${type}`,
        method: 'GET',
        params,
      }),
  },
  groupon: {
    ...CRUD('shop/admin/activity/groupon', ['list', 'detail']),
    addUser: (id, data) =>
      request({
        url: 'shop/admin/activity/groupon/addUser/' + id,
        method: 'POST',
        data,
      }),
    invalid: (id) =>
      request({
        url: 'shop/admin/activity/groupon/invalid/' + id,
        method: 'POST',
      }),
  },
};

export { route, api };
